﻿<% @title = "#{t :muonsach}" %>
<h3><%= t :muonsach %></h3>

<% if(session[:user_id]==nil) %>
  <h4><%= t :dangnhapthuchien %></h4>
  <br/>
  <p><%= link_to "=> #{t :dangnhap}", login_path %></p>
<%else%>
  <% @user = User.find(session[:user_id]) %>
  <% if(@user.GroupUserId!=10) %>
      <h4><%= t :dangnhapthuchienAdmin %></h4>
      <br/>
      <p><%= link_to "=> #{t :dangnhap}", login_path %></p>
  <%else%>

<br/>

<%= form_for(@borrowedtable) do |f| %>
  <% if @borrowedtable.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@borrowedtable.errors.count, "error") %> prohibited this borrowedtable from being saved:</h2>

      <ul>
      <% @borrowedtable.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
      
  </div>
  <% end %>    
  
  <div class="field">
  <% @Product= Product.all %>
  <%= f.label :product_id,"#{t :manuoc}" %>
  <%= f.select:product_id, @Product.map {|p| [ p.product_id, p.product_id ] }  %>  
  </div>
  
  <div>
  
  <%@pro = Product.find(:all, :conditions => ['product_id = ?',"#{@borrowedtable.product_id}"])%>
  <%  @pro.each do |pro| %>
  <p>
  <b> Tên Sách  </br>
  <%@borrowedtable.NameOfDrink = pro.Name%>
  </p>
  </b>
  <%end%>
  </div>

   <%= f.hidden_field :NameOfDrink, :value => @borrowedtable.NameOfDrink %>
   <div class="field">
    <% @User= User.all %>
  <%= f.label :NameOfBorrow,"#{t :nguoimuon}" %>
  <%= f.select :NameOfBorrow , @User.map {|p| [ p.firstName + p.lastName, p.firstName + p.lastName ] } %>
  </div>
    
    <div class="field">
  <%= f.label :BorrowedDate, "#{t :ngaymuon}" %>
  <%= f.date_select :BorrowedDate, :start_year => 2012 , :use_month_numbers => true ,:order => [:day,:month,:year]%>
    </div>
    
    <div class="field">
  <%= f.label :Deadline, "#{t :hantrasach}" %>
  <%= f.date_select :Deadline, :start_year => 2012 , :use_month_numbers => true ,:order => [:day,:month,:year]%>
    </div>
  
  <div class="actions">
    <%= f.submit "#{t :xacnhan}" %>
  </div>
<% end %>
<%end%>
<%end%>

